﻿using PlayerScannerCore.ViewModel;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace PlayerScanner
{
    public class WeaponCompactConverter : IMultiValueConverter
    {
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            var ret = String.Empty;

            if (values != null)
            {
                //Extract the properties
                var itemName = (string)values[0];
                var isUntekked = (bool)values[1];
                var isBasic = (bool)values[2];
                var special = (string)values[3];
                var grind = (int)values[4];
                var nativeBonus = (int)values[5];
                var aBeastBonus = (int)values[6];
                var machineBonus = (int)values[7];
                var darkBonus = (int)values[8];
                var hitBonus = (int)values[9];
                var kills = (int)values[10];

                var sb = new StringBuilder();

                //Build the string
                if (isUntekked)
                    sb.Append("(UNTEKKED)  ");
                if (isBasic && special != "None")
                    sb.Append(special).Append("  ");
                sb.Append(itemName);
                if (grind > 0)
                    sb.Append(" + ").Append(grind);
                sb.Append("  ").Append(nativeBonus).Append("/")
                    .Append(aBeastBonus).Append("/")
                    .Append(machineBonus).Append("/")
                    .Append(darkBonus).Append("/")
                    .Append(hitBonus);
                if (kills > 0)
                    sb.Append("  Kills: ").Append(kills);
                ret = sb.ToString();
            }

            return ret;
        }

        public object[] ConvertBack(object value, Type[] targetType, object parameter, CultureInfo culture)
        {
            // Do nothing
            return null;
        }
    }
}
